function add_note() {
	var input_element = document.getElementById('note-input');
	var new_note = document.getElementById('note-demo').cloneNode(true);

	new_note.removeAttribute('id');
	new_note.querySelector('.number').innerHTML = document.getElementById('content').querySelectorAll('.note').length;
	new_note.querySelector('.literal').innerHTML = input_element.value;

	document.getElementById('content').appendChild(new_note);
}

function remove_all_note() {
	var content = document.getElementById('content');
	var notes = content.querySelectorAll('.note');

	for (var idx = 1; idx < notes.length; idx += 1) {
		content.removeChild(notes[idx]);
	}
}

function assign_number() {
	// Reset note's number
	var content = document.getElementById('content');
	var notes = content.querySelectorAll('.note');
	for (var idx = 1; idx < notes.length; idx += 1) {
		notes[idx].querySelector('.number').innerHTML = idx;
	}
}

function remove_element(target) {
	target.parentNode.removeChild(target);

	assign_number();
}

function reverse_all_note() {
	var content = document.getElementById('content');
	var notes = content.querySelectorAll('.note');
	
	remove_all_note();

	for (var idx = notes.length - 1; idx > 0; idx -= 1) {
		content.appendChild(notes[idx]);
	}

	assign_number();
}

function light(target) {
	if (target.innerHTML == '关灯') {  // Close
		target.innerHTML = '开灯';
		document.getElementById('menu').style.backgroundColor = 'rgb(10, 10, 10)';
		document.getElementById('content-container').style.backgroundColor = 'rgb(90, 90, 90)';
	}
	else {  // Open
		target.innerHTML = '关灯';
		document.getElementById('menu').style.backgroundColor = 'rgb(255, 208, 0)';
		document.getElementById('content-container').style.backgroundColor = 'rgb(255, 239, 168)';
	}
}

function highlight(target) {
	target.style.height = '80px';
}

function lowlight(target) {
	target.style.height = '60px';
}


function set_background_color(color) {
	document.getElementById('content-container').style.backgroundColor = color;
}
